package cn.bugstack.mybatis.mapping;

/**
 *     <select id="queryUserInfo" parameterType="cn.bugstack.mybatis.test.po.User" resultType="cn.bugstack.mybatis.test.po.User">
 *         SELECT id, name
 *         FROM user
 *         where id = #{id}
 *     </select>
 *     映射sql
 */
public class MappedStatement {

    private SqlCommandType sqlCommandType;

    private String id;
    private String parameterType;
    private String resultType;
    private String sql;

    // 内部类 Builder 实现建造者模式来创建 MappedStatement
    public static class Builder {
        private MappedStatement mappedStatement = new MappedStatement();

        public Builder(String id,SqlCommandType sqlCommandType,String parameterType,String resultType,String sql) {
            mappedStatement.id = id;
            mappedStatement.sqlCommandType = sqlCommandType;
            mappedStatement.parameterType = parameterType;
            mappedStatement.resultType = resultType;
            mappedStatement.sql = sql;
        }
        public MappedStatement build() {
            assert mappedStatement.id != null;
            return mappedStatement;
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParameterType() {
        return parameterType;
    }

    public void setParameterType(String parameterType) {
        this.parameterType = parameterType;
    }

    public String getResultType() {
        return resultType;
    }

    public void setResultType(String resultType) {
        this.resultType = resultType;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public SqlCommandType getSqlCommandType() {
        return sqlCommandType;
    }

    public void setSqlCommandType(SqlCommandType sqlCommandType) {
        this.sqlCommandType = sqlCommandType;
    }
}
